package controller;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenuItem;
import javax.swing.JPopupMenu;

import view.TableComponent;

import model.Card;
import model.CardStack;

public class RightClickMenu extends JPopupMenu 
{
    JMenuItem shuffleItem;
    JMenuItem flipItem;
    JMenuItem spreadItem;
    
    CardStack stack;
    final TableComponent table;
    
    public RightClickMenu(final TableComponent table)
    {
   
        stack = null;
        this.table = table;
        
        shuffleItem = new JMenuItem("Shuffle");
        shuffleItem.addActionListener(new ActionListener() 
        {
        	private TableComponent t = table;
			
			public void actionPerformed(ActionEvent e) 
        	{
        		MetaDeckController.getInstance().getGame().shuffleTableSelection();

        		t.repaint();
        	}
        });
        shuffleItem.setEnabled(false);
        
        
        flipItem = new JMenuItem("Flip");
        flipItem.addActionListener(new ActionListener() 
        {
        	private TableComponent t = table;
			
			public void actionPerformed(ActionEvent e) 
        	{
				MetaDeckController.getInstance().getGame().flipTableSelection();

        		t.repaint();
        	}
        });
        flipItem.setEnabled(false);
  
        spreadItem = new JMenuItem("Spread");
        spreadItem.addActionListener(new ActionListener() 
        {
        	private TableComponent t = table;
			
			public void actionPerformed(ActionEvent e) 
        	{
				MetaDeckController.getInstance().getGame().spreadTableSelection();

        		t.repaint();
        	}
        });
        spreadItem.setEnabled(false);
        
        add(flipItem);
        add(shuffleItem);
        add(spreadItem);
        
        flipItem.setEnabled(true);
		shuffleItem.setEnabled(true);
		spreadItem.setEnabled(true);
    }

}
